/*
* ============================================================================
*  Name        : sea_platform_qt.cpp
*  Part of     : Finite state machine framework 
*  Description : 
*  Version     : %version: %
*  
*
* ============================================================================
*/

#include "sea_platform.h"
#include "sea_trace.h"

/**
 * @file sea_platform_qt.cpp
 *
 * @ingroup Platforms
 */
using namespace sea;

QThread::Priority OsThread::m_native_priority[ ] =
{
    QThread::LowestPriority,
    QThread::LowPriority,
    QThread::NormalPriority,
    QThread::HighPriority,
    QThread::HighestPriority
};


// -------------------------------------------------------------------------------------------------
// Trace function
// -------------------------------------------------------------------------------------------------
int Trace::Print( const char* format_str, ... )
{
    static OsMutex traceLock;
    OsMutex::Scoped safe( &traceLock );

    QString buf;
    va_list arg_list;
    va_start( arg_list, format_str );
    if ( format_str )
    {
        buf.vsprintf( format_str, arg_list );
    }
    va_end( arg_list );

    QString output;
    QTime time = QDateTime::currentDateTime( ).time( );

    output.sprintf( "%02u:%02u:%02u.%03u ", time.hour( ), time.minute( ), time.second( ), time.msec( ) );
    output += buf;

    qDebug( output.toLocal8Bit( ).constData( ) );

    return 0;
}

